<?php
	function _log ($string) {
		echo "<pre>" . $string  . "</pre>";
	}

	function debug ($object) {
		$debug_string = "";
		$debug_string = print_r($object, true);
		echo "<pre>" . $debug_string . "</pre>";
		die();
	}
	
	function make_seed () {
		list($usec, $sec) = explode(' ', microtime());
		return (float) $sec + ((float) $usec * 100000);
	}
	
	function random ($max = 100) {
		mt_srand(make_seed());
		$randval = mt_rand();
		return $randval%$max;
	}

	function valid_url ($url) {
		if (empty($url) || $url == "" || $url == "undefined" || $url == "URL")
			return false;
		if (preg_match(';[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?;', $url) == 0) // If this URI CHECKER RegExp didn't work, dropping processing
			return false;
		
		/* some regexp magic will be here soon */
		return true;
	}

	function restore_url($url) {
		$url = preg_replace(';(((htt)|(ft))(t*)p(s?):)(//(/*))?;', '$2p$6://', $url);
		if (preg_match(';((http|ftp)(s?)(://)?);', $url) == 0) $url = 'http://'.$url;
		$url = addslashes($url);
		return $url;
	}

	function e($obj) {
		if (isset($obj) && !empty($obj))
			return true;
		else
			return false;
	}

?>